package JUnit;

import static org.junit.Assert.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import algorithm.TAN;
/**
 * @version 1.0
 * @author Jonas Untiet
 *
 */
public class ExternalIPTest {

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testexternalIP() throws IOException {
		URL externalIP = new java.net.URL("http://queryip.net/ip/");  	   
				BufferedReader BR = new BufferedReader(new InputStreamReader(
				externalIP.openStream()));
		String exIP = BR.readLine();
		TAN tan = TAN.getInstance();
		String t = tan.getExternalTAN();
		String IP = tan.getIPFromTan(t);
			assertEquals(exIP, IP);   
	}

}
